Skip to content

test_parse_files.py updates#21

Closed
dougVanny wants to merge 1 commit intostevearc:masterfrom
dougVanny:test_parse_files_update
Closed

test_parse_files.py updates#21
dougVanny wants to merge 1 commit intostevearc:masterfrom
dougVanny:test_parse_files_update

Conversation

@dougVanny
Copy link
Contributor

test_parse_files.py now using difflib and attempting to supress non-meaningful differences between parsed and original files

  • Adds --verbose and -v to enable printing each tested file path
  • Adds --all option to test all files even if one fails
  • handling input files content and parsed output to remove as many whitespace characters as possible, avoid changes when, for example, loading a resource saved with a Godot version that adds whitespaces where the updated current parser might not add them (see Remove GDObject serialization white spaces #17 and Parser updates #19)
  • Adds --unescape to attempt to unescape all strings in the input and parsed output (see String output matching Godot 4.6 behavior #20)
  • Replacing previous diff logic by difflib, which is a builtin lib for generating diffs between two files

…eaningful differences between parsed and original files
@dougVanny dougVanny mentioned this pull request Feb 18, 2026
Copy link
Owner

@stevearc stevearc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this script when I thought it was possible to ensure that godot_parser always outputs data in the same format as Godot itself. If that's not possible, then I think I would prefer a different approach entirely instead of trying to hack the formats into closer similarity.

It's not as robust of a test, but we could do something like:

a = load(file)
a_str = a.serialize()
b = load(a_str)
assert(a_str == b.serialize()

@dougVanny
Copy link
Contributor Author

I wrote this script when I thought it was possible to ensure that godot_parser always outputs data in the same format as Godot itself

It is not impossible to do so, but different Godot versions output files differently. This becomes specially weird since, when updating a Godot project to a newer version, it doesn't save all resources again, so in a single project you might end up with files stored in different versions

The script itself was very useful for me, but I understand why you'd prefer not to sanitize the diff too much. I've been doing some deeper research on how Godot stores its resources across multiple different versions and I think it will be possible to make this check with much less invasive changes to the generated files

@dougVanny
Copy link
Contributor Author

Closing in favor of #22

@dougVanny dougVanny closed this Feb 24, 2026
@dougVanny dougVanny deleted the test_parse_files_update branch March 1, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants